﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter07.ViewModel
{
    using Chapter07.View;

    public class Document
    {
        public event EventHandler<DocumentClosedEventArgs> Closd;

        private string fileName;
        private FileViewerWindow fileView;

        public string FileName
        {
            get { return fileName; }
            set { fileName = value; }
        }

        public FileViewerWindow FileView
        {
            get { return fileView; }
            set { fileView = value; }
        }

        public Document(string fileName, FileViewerWindow fileView)
        {
            this.fileName = fileName;
            this.fileView = fileView;
            fileView.Closed += (sender, e) => OnClosed(new DocumentClosedEventArgs(fileName, fileView, this));
        }

        protected void OnClosed(DocumentClosedEventArgs e)
        {
            if (Closd != null)
            {
                Closd(this, e);
            }
        }
    }
}
